package
{
	import models.vo.ChatMsgVO;
	import models.vo.UserVO;
	
	import org.dexter.sendDexterEvent;

	public class ChatController
	{
		public function ChatController()
		{
		}
		[DexterExternal]
		public function chatSubmit(content:String,type:*):void{
			var msg:ChatMsgVO = new ChatMsgVO();
			msg.content = content;
			msg.name = UserVO.self.name;
			msg.userId = UserVO.self.id;
			msg.time = new Date().toLocaleTimeString();
			sendDexterEvent("broadcast","receiveChat",msg,type);
		}
		[DexterEvent]
		public function $receiveChat(content:Object,type:*):void{
			sendDexterEvent("callJs","chatReceive",content,type);
		}
		[DexterExternal]
		public function chatToSomeBody(content:String,user:Object):void{
			var msg:ChatMsgVO = new ChatMsgVO();
			msg.content = content;
			msg.name = UserVO.self.name;
			msg.userId = UserVO.self.id;
			msg.time = new Date().toLocaleTimeString();
			sendDexterEvent("sendToUser",user.groupAddress,"receiveChat",msg,"private");
			sendDexterEvent("callJs","chatReceive",msg,"private");
		}
	}
}